// 文件服务
import axios from '@/api/request/request'

// 批量文件的上传
const fileUploads = (option: any) => {
  return axios.upload('/file/file/fileUploads', option)
}

// 对象存储文件上传
const objectUploadFile = (option: any) => {
  return axios.upload('/file/file/objectUploadFile', option)
}

// 下载文件
const download = (option: any) => {
  const arr: any[] = []
  Object.keys(option).forEach((key: string) => {
    arr.push(`${key}=${option[key] || ''}`)
  })
  return axios.get(`/file/file/download?${arr.join('&')}`, {})
}

// 删除文件
const deleteFile = (option: any) => {
  return axios.post('/file/file/deleteFile', option)
}

export { fileUploads, objectUploadFile, deleteFile, download }
